package cn.webrx;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class List4 {
    public static void main(String[] args) {
        //数组转换为List
        int[] n1 = {10,20,30};
        Integer[] n2 = {100,200,300};

        List<int[]> list1 = new ArrayList(Arrays.asList(n1));
        System.out.println(list1.size());

        List<Integer> list2 = new ArrayList<>(Arrays.asList(n2));
        System.out.println(list2);

        //List 转换为 Array
        List<Integer> list = List.of(1,2,3,4,5);
        System.out.println(list);

        Object[] n3 =  list.toArray();
        System.out.println(n3);

        Integer[] n4 = new Integer[list.size()];
        list.toArray(n4);
        System.out.println(n4);//直接输入n4数组对象的ID
        System.out.println(n4 instanceof Integer[]);//判断一个对象是不是某类
        System.out.println(Arrays.asList(n4)); //List
        System.out.println(Arrays.toString(n4));//String

    }
}
